﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WishingWall.aspx.cs" Inherits="WishingWall" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>许愿墙-<%=web.WebName%></title>
    <meta name="keywords" content=<%="\""+web.Keyword+"\""%>  />
    <meta name="description" content= <%="\""+web.Description+"\"" %>  />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/css/WishingWall.css") %>" />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/css/WishNote.css?id=2") %>" />
    <%if (false)
      { %>
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <% } %>
    <script src='<%=ResolveUrl("~/Scripts/jquery-1.4.1.min.js")%>' type="text/javascript"></script>
    <script type="text/javascript" src='<%=ResolveUrl("~/Scripts/pngfix.js")%>'></script>
    <script type="text/javascript" src='<%=ResolveUrl("~/Scripts/DD_belatedPNG_0.0.8a-min.js")%>'></script>
    <script type="text/javascript" src='<%=ResolveUrl("~/Scripts/noteswall.js?id=2")%>'></script>
    <script type="text/javascript">
        var bdheight = document.documentElement.clientHeight; //获取浏览器窗体高度
        var bdwidth = document.documentElement.clientWidth; //获取浏览器窗体宽度
        var con_bodyhHeight = 0;
        jQuery(document).ready(
            function () {
                setConBodyHeight(); //高度初始化
                noteDrag.init(bdwidth - 210, con_bodyhHeight - 151); //初始化贴纸范围
                setSendBodyTop(); //设置send_body顶部位置
                jQuery("#main_mask").css("height", bdheight + "px");
                jQuery(".note").each(//初始化各个贴纸的位置
                    function () {
                        var l = parseInt(Math.random() * (bdwidth - $(this).width()) + 1);
                        var t = parseInt(Math.random() * (con_bodyhHeight - $(this).height()) + 1);
                        $(this).css("left", l + "px");
                        $(this).css("top", t + "px");
                    }
                );
                if (jQuery("#div_switch").val() == "1") {
                        sendbodyShow();
                }
                jQuery("#send_a").click(
                    function () {
                        sendbodyShow();
                    }
                );
                jQuery("#sned_close").click(
                    function () {
                        sendbodyHide();
                    }
                 );
            }
        );
        var setConBodyHeight = function () {
            con_bodyhHeight = bdheight - jQuery('#top_body').outerHeight() - jQuery('#foot_body').outerHeight();
            jQuery("#con_body").css('height', con_bodyhHeight + "px");
        }
        var setSendBodyTop = function () {
            var send_body = jQuery("#send_body");
            send_body.css('top', (bdheight / 2 - send_body.outerHeight() / 2) + "px");
        }
        var sendbodyShow = function () {
            jQuery("#send_body").css("display", "block");
            jQuery("#main_mask").css("display", "block");
            jQuery("#div_switch").val("1");

        }
        var sendbodyHide = function () {
            jQuery("#send_body").css("display", "none");
            jQuery("#main_mask").css("display", "none");
            jQuery("#div_switch").val("0");
        }
        var change_code = function () {
            //更新验证码
            document.getElementById("check_code").src = '<%=ResolveUrl("~/UserControl/CheckCode.aspx?r= ") %>' + Math.random();
        }

        var isInteger = function (s) {
            //检测字符是否为数字
            var pattern = /^([-]){0,1}([0-9]){1,}([.]){0,1}([0-9]){0,}$/;
            if (!pattern.test(s))
                return false;
            return true;
        }

        var check_name_tb = function () {
            if (jQuery("[id$=name_tb]").val().length == 0) {
                alert("请输入您的姓名");
                return false;
            }
            return true;
        }
        var check_toname_tb = function () {
            if (jQuery("[id$=toname_tb]").val().length == 0 ) {
                alert("请问您要祝福谁");
                return false;
            }
            return true;

        }
        var check_qq_tb = function () {
            if (jQuery("[id$=qq_tb]").val().length == 0) {
                alert("请留下你的QQ");
                return false;
            }
            if (!isInteger(jQuery("[id$=qq_tb]").val())) {
                alert("QQ必须为数字，请正确填写您的QQ");
                return false;
            }
            return true;
        }
        var check_lei_ddl = function () {
            if (jQuery("[id$=lei_ddl]").val()== 0) {
                alert("请选择祝福类型");
                return false;
            }
            return true;
        }
        var check_game_tb = function () {
            if (jQuery("[id$=game_tb]").val().length == 0) {
                alert("请输入祝福语");
                return false;
            }
            if (jQuery("[id$=game_tb]").val().length >45) {
                alert("祝福内容只能输入不多于　45　个字");
                return false;
            }
            return true;
        }
        var check_ycode_tb = function () {
            if (jQuery("[id$=ycode_tb]").val().length == 0) {
                alert("请输入验证码");
                return false;
            }
            return true;
        }
        var check_submit = function () {
        //提交验证输入是否正确
            if (!check_name_tb())
                return false;
            if (!check_toname_tb())
                return false;
            if (!check_qq_tb())
                return false;
            if (!check_lei_ddl())
                return false;
            if (!check_game_tb())
                return false;
            if (!check_ycode_tb())
                return false;
            return true;
        }
        var hitPraise = function (obj, ni) {
            var hitb = obj;
            $(hitb).removeAttr("onclick");
            jQuery.get('<%=ResolveUrl("~/Ajax/M_Hit_Praise.ashx")%>', { i: ni }, function (resoult) {
                if (resoult != "-1") {
                    //                    alert($(hitb).find(".hit_count").text());
                    $(hitb).find(".hit_count").html(resoult);
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="main_mask" class="pngFix">
    </div>
    <div id="send_body" class="pngFix">
        <asp:HiddenField ID="div_switch" runat="server" Value="0"/>
        <div id="send_body_in">
            <table>
                <tr>
                    <td colspan="3" style=" background-color:#8fd3fe;">
                        <a href="javascript:void(0)" id="sned_close" ></a>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        输入你的祝福纸条内容<font color="#ff0000">（只能输入不多于　45　个字）</font>
                    </td>
                    <td rowspan="5" style=" width:200px;">
                        <div class="notePreview">
                            <div class="xumain">
                                <div class="hands">
                                    <span class="close" >
                                </span>
                                </div>
                                <div class="coimg">
                                    <span id="keytoname">自己</span>
                                </div>
                                <div class="text">
                                    &nbsp;&nbsp;&nbsp;<span id="keygame">祝福内容预览</span>
                                </div>
                                <div class="user">
                                    <span id="keyname">匿名</span>
                                </div>
                                <div class="qdate">
                                    <span class="qqsp">
                                        <span id="keyqq"></span>
                                    </span> 
                                    <span class="dsp">
                                            <%=DateTime.Now.ToString("yyyy-MM-dd") %>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="send_td_left">
                        您的姓名：
                    </td>
                    <td>
                        <asp:TextBox ID="name_tb" Text="匿名" MaxLength="8" onclick="if(this.value =='匿名') this.value='';" onkeyup="keyname.innerHTML=this.value;" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="send_td_left">
                        您要祝福谁：
                    </td>
                    <td>
                        <asp:TextBox ID="toname_tb" MaxLength="8" runat="server" onkeyup="keytoname.innerHTML=this.value;"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="send_td_left">
                        您的QQ：
                    </td>
                    <td>
                        <asp:TextBox ID="qq_tb" runat="server" MaxLength="13"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="send_td_left">
                        选择类型：
                    </td>
                    <td>
                        <asp:DropDownList ID="lei_ddl" runat="server">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="send_td_left">
                        祝福语：
                    </td>
                    <td colspan="2" style=" padding:5px 0px 5px 0px;">
                        <asp:TextBox ID="game_tb" runat="server" MaxLength="45" TextMode="MultiLine" onkeyup="keygame.innerHTML=this.value;" style=" width:95%; height:70px;"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="send_td_left">验证码：
                    </td>
                    <td colspan="2">
                        <asp:TextBox ID="ycode_tb" runat="server"></asp:TextBox>
                        <a href="javascript:void();" onclick="change_code(); return false;">
                           <img alt="换一个验证码" src='<%=ResolveUrl("~/UserControl/CheckCode.aspx") %>' id="check_code" style=" height:22px; width:60px; margin-bottom:-6px; border:0px;"/>
                        </a>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <asp:Button ID="submit_btn" runat="server" Text="保存我的愿望" OnClick="submit_btn_Click" OnClientClick="return check_submit();"
                            style=" float:right; margin-right:10px;" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="top_body" class="pngFix">
        <a href='<%=ResolveUrl("~/") %>' class="menu_a" style="left: 185px; top: 56px;">网站首页</a>
        <a href='javascript:void(0)' class="menu_a" id="send_a" style="left: 580px; top: 14px;">
            <img src='<%=ResolveUrl("~/Images/56.gif") %>' style="margin-right: 8px;" alt="" />我要祝福
        </a>
    </div>
    <div id="con_body" class="pngFix">
        <asp:Repeater ID="nodelist_rp" runat="server">
            <ItemTemplate>
                <div name="note" class="note" style='z-index: <%#(this.pagesize+10-Container.ItemIndex)%>;'>
                    <div class="xumain">
                        <div class="hands">
                            <%#(nowpages == 1 & Container.ItemIndex < 3) ? "<img class='new_icon' src='" + ResolveUrl("~/Images/new_msg.gif") + "' alt='' />" : ""%>
                            <span class="close" onclick="closeDiv(this)"></span>
                        </div>
                        <div class="coimg">
                            <%# Eval("qtname")%>
                        </div>
                        <div class="text">
                            &nbsp;&nbsp;&nbsp;
                            <%#(nowpages == 1 & Container.ItemIndex < 3) ? "<font color='#008fd0'>" + Eval("qgame") + "</font>" : Eval("qgame")%>
                            
                        </div>
                        <div class="user">
                            <%# Eval("qname")%>
                        </div>
                        <div class="qdate">
                            <span class="qqsp">
                                <a href="javascript:void(0);" onclick='hitPraise(this,<%#Eval("id") %>);'>
                                    <img src='<%=ResolveUrl("~/Images/m_hit_icon.png")%>' alt=""/>
                                    <span class="hit_count"><%# Convert.ToInt32( Eval("qhits"))==0 ? "赞" : Eval("qhits")%></span>
                                </a>
                            </span> 
                            <span class="dsp">
                                    <%# FormatTime.format( Eval("qdate").ToString()) %>
                            </span>
                        </div>
                    </div>
                </div>
            </ItemTemplate>
        </asp:Repeater>
    </div>
    <div id="foot_body">
        <span id="page_sp" style="position: relative; width: 540px; left: 50%; margin-left: -270px;display: inline-block;">
            <asp:LinkButton ID="toone" runat="server" OnClick="toone_Click">[首页]</asp:LinkButton>
            <asp:LinkButton ID="toup" runat="server" OnClick="toup_Click">[上一页]</asp:LinkButton>&nbsp;
            <asp:LinkButton ID="tonext" runat="server" OnClick="tonext_Click">[下一页]</asp:LinkButton>
            <asp:LinkButton ID="tolast" runat="server" OnClick="tolast_Click">[尾页]</asp:LinkButton>&nbsp;
            [跳转到第
            <asp:DropDownList ID="jumppage" runat="server" OnSelectedIndexChanged="jumppage_SelectedIndexChanged"
                AutoPostBack="true" Style="height: 20px; margin-left: 3px; margin-bottom: -3px;">
            </asp:DropDownList>
            页]&nbsp;&nbsp; [页次:<asp:Label ID="curpage" runat="server" ForeColor="red"></asp:Label>
            /
            <asp:Label ID="sumpage" runat="server" Text="Label"></asp:Label>页] [共<asp:Label ID="pagesum"
                runat="server" Text="Label" ForeColor="red"></asp:Label>项
            <asp:Label ID="tpagesizes" runat="server" Text="Label" ForeColor="red"></asp:Label>项/页]
        </span>
        <div id="foot_msg">
            <%=web.BottomText%>
            &nbsp;&nbsp;&nbsp;powered by davis
            <%if( Page.Request.UserHostAddress.Substring(0,3)!="192")%>
                    <%=web.OutHits%>
        </div>
    </div>
    </form>
</body>
</html>
